<!doctype html>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<html>
<head>
<meta charset="utf-8">
<jsp:include page="/common/commonCss.jsp"/>
<jsp:include page="/common/commonJs.jsp"/>
<link rel="stylesheet" type="text/css" href="${basePath }commonCss/css/global.css">
<link rel="stylesheet" type="text/css" href="${basePath }commonCss/css/layout.css">
<link rel="stylesheet" type="text/css" href="${basePath }commonCss/css/easyui.css">
<script src="${basePath }commonJs/jquery.min.js"></script>
<script src="${basePath }commonJs/jquery.easyui.min.js"></script>
<script src="${basePath }commonJs/jt_normal.js"></script>
<script src="${basePath }commonJs/jt_select.js"></script>
<script src="${basePath }commonJs/tags/My97DatePicker/WdatePicker.js"></script>

<script src="${basePath }commonJs/promotion/wolf_common.js"></script>
<script src="${basePath }commonJs/promotion/wolf_validation.js"></script>
<title>房间管理</title>
</head>
<script type="text/javascript">
	$(document).ready(function(){
		seacheBatch();
	});
	function seacheBatch(){
		var form = $("#sms_home_form"); 
	    var pagebean = new PageBean(form);
	    pagebean.setTableId("sms_home_table");
	    pagebean.setCallback(seacheBatchCall);
	    pagebean.setFootId("sms_home_page");
	    setPagebeanObj(pagebean); 
	    pagebean.doPage();
	}
	function seacheBatchCall(data){
		if(wolf.isNotNull(data)){
			wolf.data_foreach(data, function(i,batch){
				var batchId = batch.pkBatchId;
				var status = batch.status;
				
				var html_edit= "<a href=\"${basePath }sms/batch/updateBatchHome.shtml?pkBatchId="+batchId+"\">"+batchId+"</a>";
				var html_delete = "<input type=\"button\" value=\"删除\" onClick=\"deleteBatch('"+batchId+"')\" class=\"btn_l\">";
				var html_close = "<input type=\"button\" value=\"关闭\" onClick=\"closeBatch('"+batchId+"')\" class=\"btn_l\">";
				var html_lab = batchId;
				var html_info= "<a href=\"${basePath }sms/batch/searcheInf.shtml?pkBatchId="+batchId+"\">"+batchId+"</a>";
				
				
				var tr = "<tr>"+
			            	"<td class=\"lv\">_edit_</td>"+
			                "<td>"+batch.branName+"</td>"+
			                "<td>"+(batch.status==1?'草稿':batch.status==2?'提交':batch.status==3?'已发送':'')+"</td>"+
			                "<td title='"+batch.context+"'>"+(batch.context.length > 15?batch.context.substr(0,15)+"...":batch.context.substr(0,15))+"</td>"+
			                "<td>"+batch.planTimeStr+"</td>"+
			                "<td>_delete__close_</td>"+
			            "</tr>";
			     if(status == 1){
			    	 tr = tr.replace("_edit_",html_edit);
			    	 tr = tr.replace("_delete_",html_delete);
			    	 tr = tr.replace("_close_","");
			     }else if(status == 2){
			    	 tr = tr.replace("_edit_",html_edit);
			    	 tr = tr.replace("_delete_","");
			    	 tr = tr.replace("_close_",html_delete);
			     }else if(status == 3){
			    	 tr = tr.replace("_edit_",html_info);
			    	 tr = tr.replace("_delete_","");
			    	 tr = tr.replace("_close_","-");
			     }
			    $("#sms_home_table").append(tr);
			});
		}
	}
	function deleteBatch(batchId){
		$.messager.confirm('提示', '你确定要删除吗?', function(r) {
			if (r) {
				$.ajax({ 
					url: "${basePath }sms/batch/deleteBatch.shtml",
					data:"pkBatchId=" + batchId,
					async:false,
					dataType: 'json',
					type:'POST',
					success: function(data){
						seacheBatch();
			      	}
				});
			}
		});
	}
	function closeBatch(batchId){
		$.messager.confirm('提示', '你确定要关闭吗?', function(r) {
			if (r) {
				$.ajax({ 
					url: "${basePath }sms/batch/updateBatchClose.shtml",
					data:"pkBatchId=" + batchId,
					async:false,
					dataType: 'json',
					type:'POST',
					success: function(data){
						seacheBatch();
			      	}
				});
			}
		});
	}
</script>
<body class="bg">
<div class="content m_auto">
	<div class="content_l mt10">
    	<ul>
            <shiro:hasPermission name="sms/batch/home.shtml">
            	<li class="content_hover"><a href="${basePath}sms/batch/home.shtml"><i class="nav_icon_v"></i><br>短信发送</a></li>
        	</shiro:hasPermission>
        </ul>
    </div>
    <div class="content_r mt10">
    	<!---- 内容 --->
        <div class="p20">
        <form action="${basePath }sms/batch/seacheHome.shtml" id="sms_home_form">
	        <div class="file_single_dl ">
	        	<dl>
	            	<dd><label>所属门店：</label>
	                	<div class="uboxstyle">
	                         <select name="fkBranId" id="fkBranId">
                        		<c:forEach items="${branAll }" var="bran" varStatus="cc">
	                            	<c:choose>
	                            		<c:when test="${branId == 'ZB' }">
	                            			<c:if test="${bran.pkBranId !='ZB'}">
	                            				<option value="${bran.pkBranId}">${bran.branName }</option>
	                            			</c:if>
		                            	</c:when>
		                            	<c:when test="${branId != 'ZB' && branId ==bran.pkBranId }">
		                            		
		                            		<option value="${bran.pkBranId}">${bran.branName }</option>
		                            	</c:when>
		                            	
                            		</c:choose>
	                            </c:forEach>
	                        </select>
	                    </div>
	                </dd>
	                <dd><label>批次编号：</label><input type="text" class="iput_t w200" name="pkBatchId"></dd>
	                <dd><label>状态：</label>
	                	<div class="uboxstyle">
	                        <select name="status" id="status">
	                            <option value="">全部</option>
	                            <option value="1">草稿</option>
	                            <option value="2">提交</option>
	                            <option value="3">已发送</option>
	                        </select>
	                    </div>
	                </dd>
	                <dd><label>预期发送时间：</label>
	                	<input title="" type="text" name="startDates" id="date1"
						onClick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowWeek:true,isShowClear:true,readOnly:true,maxDate:'#F{$dp.$D(\'date2\')}'})"
						class="Wdate iput_t w82" readonly />
	                    至
	                    
	                	<input title="" type="text" name="endDates" id="date2"
						onClick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowWeek:true,isShowClear:true,readOnly:true,minDate:'#F{$dp.$D(\'date1\')}'})"
						class="Wdate iput_t w82" readonly />
	                </dd>
	                <dd><label>内容：</label><input type="text" class="iput_t w200" name="context"></dd>
	                <dd>
		                <input type="button" class="btn fr ml10" value="查询" onclick="seacheBatch()">
		                <input type="button" class="btn fr ml10" value="新增" onClick="javascript:window.location.href='${basePath }sms/batch/addBatchHome.shtml'">
		                <input type="button" class="btn fr  ml10" value="发送历史" onClick="javascript:window.location.href='${basePath }sms/batch/searcheBatchHisHome.shtml'"></dd>
	            </dl>
	        </div>
	        <input type="hidden" name="pageNo" value="1">
	        <input type="hidden" name="pageSize" value="15">
        </form>
        <table class="table" id="sms_home_table">
        	<tr>
            	<th>批次编号</th>
                <th>所属门店</th>
                <th>状态</th>
                <th>内容</th>
                <th>预期发送时间</th>
                <th>操作</th>
            </tr>
        </table>
        <!----翻页----->
        
        <div class="page fr m10" id="sms_home_page">
        </div>
        <!----翻页----->
        </div>
        <!---- 内容 --->
    </div>
</div>


























</body>
</html>
